
/*
工具类
*/
var Utils={

    imgLoadUrl:'http://imgload.chexiang365.net/',
    'unique_arr':function (arr) {
        return Array.from(new Set(arr));
    },
    'paraJson':function (str){
        return JSON.parse(str);
    },
    'addZero':function (value){
        return value < 10 ? '0' + value : value;
    },
    'paraseTime':function (data,type =""){
        var _data = data;
        //如果是13位正常，如果是10位则需要转化为毫秒
        if (String(data).length == 13) {
            _data = data
        } else {
            _data = data*1000
        }
        const time = new Date(_data);
        const Y = this.addZero(time.getFullYear());
        const Mon = this.addZero(time.getMonth() + 1);
        const Day = this.addZero(time.getDate());
        const H = this.addZero(time.getHours());
        const Min = this.addZero(time.getMinutes());
        const S = this.addZero(time.getSeconds());
        //自定义选择想要返回的类型
        if(type=="Y"){
            return `${Y}-${Mon}-${Day}`
        }else if(type=="H"){
            return `${H}:${Min}:${S}`
        }else{
            return `${Y}-${Mon}-${Day} ${H}:${Min}:${S}`
        }
    },
    dateStrToTimeSteamp:function (dateStr){
        if(dateStr == ''){
            return '';
        }
        let d = new Date(dateStr)
        return d.getTime()/1000;
    },
	/*成功的Toast*/
	'successToast':function(msg){
		layer.msg(msg, {
	      offset: '15px'
	      ,icon: 1
	    });
	},
	// 失败的toast
	'errorToast':function(msg){
		layer.msg(msg, {
	      offset: '15px'
	      ,icon: 2
	    });
	}
};
